//绘制一个程序，在窗口上绘制一幅图片
import javax.swing.*;//窗口组件文件
import javax.imageio.ImageIO;//图像文件
import java.awt.*;//图形文件
import java.io.*;//创建文件以及异常处理
class PaintPanel1 extends JPanel{
    Image pic;
    PaintPanel1(){
        super();
        try{
            File f=new File("E:\\JAVA\\day-up\\Work7\\图.jpg");
            pic=ImageIO.read(f);
        }
        catch(IOException e){
            System.out.println("图片文件读取失败");
        }
    }
    public void paintComponent(Graphics g){
        super.paintComponent(g);
        g.drawImage(pic,200,100,600,700,null);
    }
}
public class MyFrame1 extends JFrame {
    MyFrame1(String s){
        super(s);
        setBounds(200,250,1000,1000);

        PaintPanel1 p=new PaintPanel1();
        add(p);

        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    public static void main(String[] args) {
        new MyFrame1("绘制图像");
    }
}
